import React, { Component } from 'react'
import { connect } from 'react-redux'
import { increment, decrement, asyncIncrement } from '../../redux/actions/count_action'
class Count extends Component{
  increment = () =>{
    this.props.increment(1)
  }
  decrement = () =>{
    this.props.decrement(1)
  }
  asyncIncrement = () =>{
    this.props.asyncIncrement(1, 500)
  }
  render() {
    return (
      <div>
        <div>count:{this.props.count}</div>
        <div>
          <button onClick={this.increment}>+</button>
          <button onClick={this.decrement}>-</button>
          <button onClick={this.asyncIncrement}>异步+</button>
        </div>
      </div>
    )
  }
}
export default connect(
  state => ({ count: state }),
  {
    increment,
    decrement,
    asyncIncrement
  }
)(Count)